import BaseHttp from "./BaseHttp"

export default class User extends BaseHttp {
    constructor() {
        super()//在构造函数中使用父类的构造函数
    }

    async Login(userName, password,isRemeberMe) {
        return (await this.post('Account/Login', {
            UserName: userName,
            Password: password,
            IsRemeberMe:isRemeberMe
        }))
    }

    async Logout(token) {
        const targetToken="Bearer "+token
        return (await this.postWithParams('Account/SignOut',null,{
            Authorization:targetToken
        }))
    }

    async Register({
        userName, //用户名
        password, //密码
      }){

        return (await this.post('Account/RegisterUser', {
            UserName: userName,
            Password: password,
        }))
    }



    // ···············修改用户信息开始····················
    async ChangeUserInfo(data,token) {
        const targetToken="Bearer "+token
        return (await this.putWithParams('Account/ChangeAppUserInfo',data,{
            Authorization:targetToken
        }))
    }
    // ···············修改用户信息结束····················


    // ···············修改用户密码开始····················
    async ChangePassword(data,token) {
        const targetToken="Bearer "+token
        return (await this.putWithParams('Account/ChangePassword',data,{
            Authorization:targetToken
        }))
    }
    // ···············修改用户密码结束····················



    // ···············Get用户信息byId开始····················
    async GetUserById(id,token) {
        const targetToken="Bearer "+token;
        const targetUrl='Account/AppUsers/'+id;
        return (await this.getWithParam(targetUrl,{
            Authorization:targetToken
        }))
    }
    // ················Get用户信息byId结束····················

}